<template>
	<view class="mechanismResult ff-text-center">
		<image src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/result.png" mode=""></image>
		<view class="ff-color-5C5F65">现场执业已结束</view>
		<view class="mechanismResult-butList">
			<view class="ff-margin-bottom-30" v-if="reportState"><u-button type="primary" shape="circle" @click="goReportClick">填写报告</u-button></view>
			<view><u-button @click="goBackPage" type="primary" shape="circle" plain>返回首页</u-button></view>
		</view>
		<!-- 组件区 -->
		<u-toast ref="uToast" />
		<f-loading ref="loading" />
	</view>
</template>

<script>
export default {
	name: 'mechanismResult',
	data() {
		return {
			maintenanceId: '', // 维保项目的id
			userIds: '', // 当前用户的id
			operators: [], // 执业人员的列表数据
			reportState: false // 是否操作员，可以填写报告书
		};
	},
	onLoad(e) {
		this.maintenanceId = e.id; // 维保项目的id
		this.operators = JSON.parse(e.operators); // 执业人员的列表数据
		this.getUserInfo(); // 获取人员信息列表
	},
	onShow() {
		uni.hideHomeButton(); // 隐藏小房子
	},
	methods: {
		// 获取当前用户信息
		async getUserInfo() {
			this.$refs.loading.openLoading('加载中···');
			const data = await this.$http.get({ url: '/sys/user/info' });
			// console.log('获取当前用户信息', data);
			if (data.code == 200) {
				this.userIds = data.data.id;
				let datId = [];
				this.operators.map(res => {
					datId.push(res.userId);
				});
				if (datId.includes(this.userIds)) {
					this.reportState = true;
				} else {
					this.reportState = false;
				}
			}
			this.$refs.loading.closeLoading();
		},
		// 返回首页
		goBackPage() {
			this.$pageJump.reLaunch('/pages/maintenance/mechanism/Maintenance');
		},
		// 填写报告书
		goReportClick() {
			this.$pageJump.reLaunch('/pages/maintenance/mechanism/home/components/details/Report?id=' + this.maintenanceId);
		}
	},
	onShareAppMessage() {
		return {
			title: '分享小程序给朋友',
			path: '/pages/homePage/Home'
		};
	}
};
</script>

<style lang="scss" scoped>
.mechanismResult {
	image {
		width: 280rpx;
		height: 180rpx;
		margin: 122rpx 0 80rpx;
	}
	&-butList {
		width: 88%;
		margin: 200rpx 6% 5%;
		/deep/.u-btn--primary--plain.data-v-3bf2dba7 {
			color: #2979ff !important;
			border-color: #2979ff !important;
			background-color: #fff !important;
		}
	}
}
</style>
<style>
page {
	background-color: #fafafa;
}
</style>
